﻿using UnityEngine;
using TMPro;
using pooling;

public class ComboAnimation : PoolingObject
{
    private TextMeshPro scoreText;
    private TextMeshPro comboText;

    private void Awake()
    {
        scoreText = GetComponent<TextMeshPro>();
        comboText = transform.GetChild(0).GetComponent<TextMeshPro>();
    }

    public void InitAnimation(Vector3 position, int score)
    {
        transform.position = position + new Vector3(3,0,0);
        scoreText.color -= new Color(0, 0, 0, 1);
        scoreText.text = score.ToString();
        comboText.color -= new Color(0, 0, 0, 1);

        scoreText.LeanAlphaTextMeshPro(1, 0.6f).setEase(LeanTweenType.easeOutCubic).setOnComplete(()=> {
            scoreText.LeanAlphaTextMeshPro(0, 0.4f);
        });
        comboText.LeanAlphaTextMeshPro(1, 0.6f).setEase(LeanTweenType.easeOutCubic).setOnComplete(() => {
            comboText.LeanAlphaTextMeshPro(0, 0.4f);
        });
        gameObject.LeanMoveLocalY(transform.position.y + 2f, 1f).setEase(LeanTweenType.easeInOutQuad).setOnComplete(() =>
        {
            OnRelease();
        });
    }
}
